package com.xjtu.platform.security.mailFill.imply;

import com.xjtu.platform.security.mailFill.MailDto;
import com.xjtu.platform.security.mailFill.MailFillService;
import com.xjtu.platform.security.mailFill.dao.MailDao;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;


@Service
@Transactional
public class MailFillServiceImpl implements MailFillService {

    @Resource
    private MailDao mailDao;


    @Override
    public String getCode(String user_id) {
        try {
            return mailDao.getCode(user_id);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    @Override
    public boolean insertEmail(MailDto mailDto) {
        try {
            mailDao.insertEmail(mailDto);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }

    @Override
    public void insertCode(String code,MailDto mailDto) {
        try {
            mailDao.insertCode(code,mailDto.getUser_id());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
